//
//  ZYSportTrackingLine.m
//  LoveSport
//
//  Created by 王朝阳 on 2016/11/10.
//  Copyright © 2016年 wangzhaoyang. All rights reserved.
//

#import "ZYSportTrackingLine.h"

@implementation ZYSportTrackingLine
- (instancetype)initWithStartLocation:(CLLocation *)startLocation endLocation:(CLLocation *)endLocation
{
    self = [super init];
    if (self) {
        _startLocation = startLocation;
        _endLocation = endLocation;
    }
    return self;
}
- (ZYSportPolyline *)polyline {
    CLLocationCoordinate2D coords[2];
    coords[0] = _startLocation.coordinate;
    coords[1] = _endLocation.coordinate;
//    UIColor *color = [UIColor greenColor];
    //设置放大比例因子
    CGFloat factor = 8;
    
    
    CGFloat red = factor * self.speed / 255.0;
    
    UIColor *color = [UIColor colorWithRed:red green:1 blue:0 alpha:1];
    
    return [ZYSportPolyline polylineWithCoordinates:coords count:2 color:color];
    
}
- (double)speed {
    return (_startLocation.speed + _endLocation.speed) * 0.5 * 3.6;
}
- (NSTimeInterval)time {
    return [_endLocation.timestamp timeIntervalSinceDate:_startLocation.timestamp];
}

@end
